package alp.starcode.nudtportal.framework.common.controller;

import alp.starcode.common.dict.model.DictData;
import alp.starcode.common.result.Result;
import alp.starcode.nudtportal.framework.common.service.CommonService;
import alp.starcode.nudtportal.framework.constant.ProjectConst;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "公共接口")
@RequestMapping("common")
@RestController
public class CommonController {
    @Autowired
    CommonService commonService;

    @ApiOperation("小程序初始化调用")
    @GetMapping("init.do")
    public Result init()  {
        return Result.success();
    }

    /**
     * 获取交易类型
     *
     * @return
     */
    @ApiOperation("获取交易类型")
    @GetMapping("getTransactionTypes.do")
    public Result<List<DictData>> getTransactionTypes() throws Exception {
        return Result.success(commonService.getDictDataList(ProjectConst.DICT_TRANSACTION_TYPE));
    }

    /**
     * 获取钱包类型
     *
     * @return
     */
    @ApiOperation("获取钱包类型")
    @GetMapping("getWalletTypes.do")
    public Result<List<DictData>> getWalletTypes() throws Exception {
        return Result.success(commonService.getDictDataList(ProjectConst.DICT_TYPE_WALLET_TYPE));
    }

    /**
     * 获取流水订阅类型
     *
     * @return
     */
    @ApiOperation("获取流水订阅时长配置")
    @GetMapping("getSubscribeDurationConfig.do")
    public Result<List<DictData>> getSubscribeDurationConfig() throws Exception {
        return Result.success(commonService.getDictDataList(ProjectConst.SYS_SUBSCRIPTION_TYPE));
    }
}
